package Thread_练习3;

/**
 * @作者:侯国威
 * @时间: 2020/4/11/19:46
 * @邮箱:1045077189@qq.com
 */
public class index {
    public static void main(String[] args) {
        ThreadTest T =new ThreadTest();
        T.run();

    }

}
class ThreadTest extends Thread{
    private static int ticket=30;
    @Override
    public void run() {
       while (true){
           try {
               show();
           } catch (InterruptedException e) {
               e.printStackTrace();
           }
       }
    }
    private synchronized void show() throws InterruptedException {
        if (ticket>0){
            Thread.sleep(1000);
            System.out.println("窗口:"+currentThread().getName()+ticket);
            ticket--;
        }
    }

}
